In many cases the rule "prefer-destructuring" of ESLint is pretty weird. Consider the following example:
obj.someVar = myList[0];
The linter is warning me in both cases.
What's the expected behavior that the linter wants? I can use a temp var to save the value of the list item and later on do the rest of the logic, but I don't see any benefit in it. Any ideas what's the reason for that?
EDIT:
I can see the benefit of the rule in some situations, i.e:
// bad
const someVar = myList[0];
// good
const [ someVar ] = myList;
But when the assignment is not directly to a var (like when assigning a property of an object) the rule seems irrelevant.
What ESLint expects for obj.someVar = myList[0] is:
let obj = {};
let myList = [1,2];
[obj.someVar] = myList;
console.dir(obj);
Here is a link to an Issue about that topic prefer-destructuring flags a property assignment #11584